<?php
global $_GPC, $_W;
// $action = 'ad';
// $title = $this->actions_titles[$action];
$GLOBALS['frames'] = $this->getMainMenu();
$item=pdo_get('zh_gjhdbm_system',array('uniacid'=>$_W['uniacid']));
    if(checksubmit('submit')){
        $data['sms_key'] = trim($_GPC['appkey']);
        $data['tpl_id'] = trim($_GPC['tpl_id']);
        $data['tpl_id1'] = trim($_GPC['tpl_id1']);
        $data['tpl_id2'] = trim($_GPC['tpl_id2']);
        $data['is_dxyz'] = $_GPC['is_dxyz'];
        $data['sign_name'] = $sign_name = $_GPC['sign_name'];
        $data['sms_secret'] = $appsecret = $_GPC['appsecret'];

        if($_GPC['appkey']==''){
            message('短信应用key不能为空!','','error');
        }
        if($_GPC['tpl_id']==''){
            message('通知短信模板id不能为空!','','error');
        }
        if($_GPC['tpl_id1']==''){
            message('交警短信模板id不能为空!','','error');
        }
        if($_GPC['tpl_id2']==''){
            message('状态短信模板id不能为空!','','error');
        }
        if($appsecret==''){
            message('密钥不能为空!','','error');
        }
        if($sign_name==''){
            message('签名不能为空!','','error');
        }
        $data['uniacid']=trim($_W['uniacid']);
        if($_GPC['id']==''){
            $res=pdo_insert('zh_gjhdbm_system',$data);
            if($res){
                message('添加成功',$this->createWebUrl('sms',array()),'success');
            }else{
                message('添加失败','','error');
            }
        }else{
            $res = pdo_update('zh_gjhdbm_system', $data, array('id' => $_GPC['id']));
            if($res){
                message('编辑成功',$this->createWebUrl('sms',array()),'success');
            }else{
                message('编辑失败','','error');
            }
        }
    }
    include $this->template('web/sms');